home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hardcore Visual Basic 5.0 (2nd Edition)
/
Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso
/
Code
/
VECTOR~2.CLS
< prev
next >
Wrap
Text File
|
1997-06-14
|
2KB
|
85 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "CVectorBoolWalker"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
' Implement Basic-friendly version of IEnumVARIANT
Implements IVariantWalker
' Delegate to class that implements real IEnumVARIANT
Private vars As CEnumVariant
' Connect back to parent collection
Private connect As CVectorBool
Public Enum EErrorVectorBoolWalker
eeBaseVectorBoolWalker = 13290 ' CVectorBoolWalker
End Enum
' Private state data
Private iCur As Long
Private Sub Class_Initialize()
' Initialize position in collection
iCur = 0
' Connect walker to CEnumVariant so it can call methods
Set vars = New CEnumVariant
vars.Attach Me
End Sub
' Receive connection from CVectorBool
Sub Attach(connectA As CVectorBool)
Set connect = connectA
End Sub
' Return IEnumVARIANT (indirectly) to client collection
Function NewEnum() As stdole.IEnumVARIANT
Set NewEnum = vars
End Function
' Implement IVariantWalker methods
Private Function IVariantWalker_More(v As Variant) As Boolean
' Move to next element
iCur = iCur + 1
' Return False if no more data
If iCur > connect.Last Then Exit Function
' Return element through reference
v = connect.Vector(iCur)
IVariantWalker_More = True
End Function
Private Sub IVariantWalker_Reset()
' Move to first element
iCur = 0
End Sub
Private Sub IVariantWalker_Skip(c As Long)
' Skip a given number of elements
iCur = iCur + c
End Sub
#If fComponent = 0 Then
Private Sub ErrRaise(e As Long)
Dim sText As String, sSource As String
If e > 1000 Then
sSource = App.ExeName & ".VectorBoolWalker"
Select Case e
Case eeBaseVectorBoolWalker
BugAssert True
' Case ee...
' Add additional errors
End Select
Err.Raise COMError(e), sSource, sText
Else
' Raise standard Visual Basic error
sSource = App.ExeName & ".VBError"
Err.Raise e, sSource
End If
End Sub
#End If